﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Ingenious.MVVM;
using Ingenious.Graph;

namespace Ingenious.Core.TestHarness
{
    public class NodeViewModelItem<TTripleId> : ViewModelItem<INode<TTripleId>>, ITreeNodeViewModelItem
    {
        private bool m_isSelected;
        private bool m_isExpanded;

        private NodeViewModelList<TTripleId> m_nodeViewModelList;

        #region Object Lifetime
        public NodeViewModelItem(IViewModel parent, INode<TTripleId> node)
            : base(parent, node)
        {
        }
        #endregion

        #region Properties
        public NodeViewModelList<TTripleId> NodeViewModelList
        {
            get
            {
                if (m_nodeViewModelList == null)
                {
                    m_nodeViewModelList = new NodeViewModelList<TTripleId>(this, Model as INodeList<TTripleId>);
                }

                return m_nodeViewModelList;
            }
        }
        #endregion

        #region Properties
        public bool IsSelected
        {
            get { return m_isSelected; }
            set
            {
                if (m_isSelected != value)
                {
                    m_isSelected = value;

                    GetParentOfType<GraphViewModel<TTripleId>>().SelectedNodeItem = this;
                    NotifyOfPropertyChange(() => IsSelected);
                }
            }
        }

        public bool IsExpanded
        {
            get { return m_isExpanded; }
            set
            {
                if (m_isExpanded != value)
                {
                    m_isExpanded = value;
                    NotifyOfPropertyChange(() => IsExpanded);
                }
            }
        }
        #endregion
    }
}
